<template>
  <div>
    <header-component></header-component>
    <div class="rab_zhongjiang rab_bg">
      <div class="rab_title">
        中奖名单
      </div>
      <ul>
        <li>
          <span>用户名</span>
          <span>金额</span>
          <span>数字</span>
        </li>
        <li v-for="item in userList" v-bind:key="item.id">
          <span>{{item.user}}</span>
          <span>{{item.reward}}</span>
          <span>{{item.digital}}</span>
        </li>
        <li v-show="userList.length === 0">
          <div style="text-align: center;line-height: 60px;">没有数据</div>
        </li>
        <!--<li>-->
          <!--<span>用户名</span>-->
          <!--<span>200</span>-->
          <!--<span>5</span>-->
        <!--</li>-->
      </ul>
    </div>
    <footer-component></footer-component>
  </div>
</template>

<script>
import headerComponent from '@/view/common/header'
import footerComponent from '@/view/common/footer'

export default {
  name: 'name',
  data () {
    return {
      isBuying: false,
      gameId: '', // 游戏id
      userList: [] // 中奖名单
    }
  },
  components: {
    headerComponent,
    footerComponent
  },
  computed: {
    lang: function () {
      return this.$store.getters.getLang
    },
    account: function () {
      return this.$store.getters.getAccount
    }
  },
  created () {
    this.gameId = this.$route.params.id
    console.log(this.gameId)
    this.getData()
  },
  methods: {
    async getData () {
      await this.$scatterJs.scatter.connect(this.$config.gameName)
      let eos = this.$scatterJs.scatter.eos(this.$config.network, this.$eosjs)
      eos.getTableRows({
        code: this.$config.cont_owner,
        scope: this.$config.cont_owner,
        table: 'carbet',
        index_position: '3',
        lower_bound: this.gameId + '',
        key_type: 'i64',
        upper_bound: this.gameId + '',
        limit: 100,
        json: true
      }).then(res => {
        this.userList = res.rows
        console.log('table other:', this.preSellData)
      }).catch(e => {
        console.log('other table e:', e)
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
